package com.sjqi.demo.builer;

import com.sjqi.demo.config.Configuration;
import com.sjqi.demo.factory.SqlSessionFactory;
import com.sjqi.demo.utils.DocumentUtils;
import org.dom4j.Document;

import java.io.InputStream;
import java.io.Reader;

/**
 * @author qishaojun
 */
public class SqlSessionFactoryBuilder {

    public SqlSessionFactory build(InputStream inputStream) {
        Document document = DocumentUtils.getDocument(inputStream);
        //获取Configuration 对象
        //configurationn 委托给专业的类去做
        XMLConfigBuilder configBuilder = new XMLConfigBuilder();
        Configuration configuration = configBuilder.parseConfiguration(document.getRootElement());
        return build(configuration);
    }

    public SqlSessionFactory build(Reader reader) {
        //获取Configuration 对象
        //创建
        Configuration configuration = null;
        return build(configuration);
    }

    public SqlSessionFactory build(Configuration configuration) {
        //获取Configuration 对象
        //创建
        //TODO:Configuration 注入
        return null;
    }
}
